<template>
    <div style="width: 100%;">
        <el-page-header @back="goBack" content="投标项目列表">
        </el-page-header>
        <el-divider></el-divider>
        <el-form :inline="true">
            <el-form-item>
                <el-input v-model="params.projectName" placeholder="项目名称"></el-input>
            </el-form-item>
            <el-form-item style="margin-left: 20px">
                <el-select v-model="params.projectType" :value="params.projectType">
                    <el-option value="" label="项目类型"></el-option>
                    <el-option
                            :key="projectType.typeId"
                            v-for="projectType in projectTypeList"
                            :value="projectType.typeId"
                            :label="projectType.typeName"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item style="margin-left: 20px">
                <el-select v-model="params.approveStatus" :value="params.approveStatus">
                    <el-option label="审批状态" value=""></el-option>
                    <el-option label="审批中" value="1"></el-option>
                    <el-option label="审批不通过" value="2"></el-option>
                    <el-option label="审批通过" value="3"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item style="margin-left: 20px">
                <el-button @click="handleSearch" type="primary">检索</el-button>
            </el-form-item>
        </el-form>

        <el-table :data="pageResult.records">
            <el-table-column label="序号" type="index"></el-table-column>
            <el-table-column label="项目名称" prop="projectName"></el-table-column>
            <el-table-column label="项目类型" prop="typeName"></el-table-column>
            <el-table-column label="项目地址" prop="projectAddress"></el-table-column>
            <el-table-column label="录入人" prop="creator"></el-table-column>
            <el-table-column label="日期" prop="createDate"></el-table-column>
            <el-table-column label="投标负责人" prop="bidder"></el-table-column>
            <el-table-column label="建设单位" prop="buildCompany"></el-table-column>
            <el-table-column label="预计合同金额" prop="pretenderAmount">
                <template slot-scope="scope">{{scope.row.pretenderAmount/10000+'万'}}</template>
            </el-table-column>
            <el-table-column label="联系人" prop="contactor"></el-table-column>
            <el-table-column label="联系电话" prop="contactPhone"></el-table-column>
            <el-table-column label="流程状态" prop="approveStatus">
                <template slot-scope="scope">
                    <span style="color: orange;font-weight: 700" v-if="scope.row.approveStatus=='1'">审批中</span>
                    <span style="color: red;font-weight: 700" v-if="scope.row.approveStatus=='2'">审批不通过</span>
                    <span style="color: green;font-weight: 700" v-if="scope.row.approveStatus=='3'">审批通过</span>
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-dropdown @command="handleCommand" trigger="click">
                        <el-button>
                            操作<i class="el-icon-arrow-down el-icon--right"></i>
                        </el-button>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item :command="{row:scope.row,type:'remove'}" v-if="scope.row.approveStatus=='2'">删除</el-dropdown-item>
                            <el-dropdown-item :command="{row:scope.row,type:'update'}">查看详情</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </template>
            </el-table-column>
        </el-table>
        <el-divider></el-divider>

        <el-footer class="case-list-footer">
            <el-pagination
                    style="margin: 10px auto"
                    background
                    layout="total , sizes ,prev, pager, next,jumper"
                    :page-sizes="[5,10,15,20]"
                    :total="pageResult.total"
                    :page-size="pageResult.size"
                    class="pagination"
                    @current-change="handleIndexChange"
                    @size-change="handleSizeChange"
            >
            </el-pagination>
        </el-footer>
    </div>
</template>

<script>
    import {ProjectTypeService} from "../../../model/gs/ProjectTypeService";
    import {TenderProjectInfoService} from "../../../model/gs/TenderProjectInfoService";

    const projectTypeService = ProjectTypeService.getInstance()
    const tenderProjectInfoService = TenderProjectInfoService.getInstance()

    export default {
        data() {
            return {
                params: {
                    projectName: '',
                    projectType: '',
                    approveStatus: ''
                },
                projectTypeList:[],
                pageResult:[]
            }
        },
        methods: {
            goBack() {
                history.back()
            },
            getProjectTypeList() {
                projectTypeService.getList().then(response => {
                    if(response.data.code === 0){
                        this.projectTypeList = response.data.data
                    }
                })
            },
            getTenderProjectInfoList(){
                tenderProjectInfoService.getPageList(this.params).then(response => {
                    if(response.data.code === 0){
                        this.pageResult = response.data.data
                    }
                })
            },
            handleSearch(){
                this.params.page = 1
                this.getTenderProjectInfoList()
            },
            handleIndexChange(index){
                this.params.page = index
                this.getTenderProjectInfoList()
            },
            handleSizeChange(size){
                this.params.size = size
                this.getTenderProjectInfoList()
            },
            handleCommand(command){
                console.log(command);
            }
        },
        created(){
            this.getProjectTypeList()
            this.getTenderProjectInfoList()
        }
    }
</script>

<style scoped>
</style>
